import nester,pickle

man = []
other = []
"""
前面先剖析数据的结构 先将数据处理
"""
try:
    data =open("sketch.txt")
    for each_line in data:#遍历数据
        try:
            (role,line_spoken) = each_line.split(":",1)
            line_spoken = line_spoken.strip()
            if role == "Man":
                man.append(line_spoken)
            elif role == "Other Man":
                other.append(line_spoken)
        except ValueError:
        	pass
    data.close()
except IOError:
	print("The datafile is missing!")

try:
	with open("man_data.txt","wb") as man_file,open("other_data.txt","wb") as other_file:
		pickle.dump(man,man_file)
		pickle.dump(other,other_file)
except pickle.PickleError as err:
	print("File error" + str(err))
    
